package main

/*
*
模板模式
*/
type Cook interface {
	//倒油
	pourOil()
	//下菜
	putVegetable()
	//调味
	seasoning()
	//出锅装盘
	serveDish()
}

type template struct {
	Cook Cook
}

func (t *template) CookDish() {
	if t.Cook == nil {
		return
	}
	t.Cook.pourOil()
	t.Cook.putVegetable()
	t.Cook.seasoning()
	t.Cook.serveDish()
}

// MasterKang 做菜的师傅
type MasterKang struct {
	template
}

func (m *MasterKang) pourOil() {
	println("倒油")
}

func (m *MasterKang) putVegetable() {
	println("下菜")
}

func (m *MasterKang) seasoning() {
	println("调味")
}

func (m *MasterKang) serveDish() {
	println("出锅装盘")
}

func (m *MasterKang) Cook() {
	m.CookDish()
}

func NewMaster() *MasterKang {
	m := new(MasterKang)
	m.template.Cook = m
	return m
}

func main() {
	master := NewMaster()
	master.Cook()
}
